//
//package com.hafu.view;
//
//        import com.hafu.model.KuCun;
//        import com.hafu.service.KuCunService;
//
//        import java.awt.*;
//        import java.util.ArrayList;
//        import java.util.Vector;
//        import javax.swing.*;
//        import javax.swing.GroupLayout;
//        import javax.swing.table.*;
//
///**
// * @author zhaoxiaorui
// */
//public class KuCunFrm extends JFrame {
//    private KuCunService kuCunService = new KuCunService();
//    public KuCunFrm() {
//        initComponents();
//        //填充表格数据
//        fillTableData();
//    }
//
//    private void fillTableData() {
//        //获取表格
//        DefaultTableModel model = (DefaultTableModel) table1.getModel();
//        model.setRowCount(0);
//        //获取数据
//        ArrayList<KuCun> list = kuCunService.getKuCunList();
//        for (KuCun kuCun : list) {
//            Vector<Object> rowDate = new Vector<>();
//            rowDate.add(kuCun.getId());
//            rowDate.add(kuCun.getSpname());
//            rowDate.add(kuCun.getNum());
//            //添加一行数据
//            model.addRow(rowDate);
//        }
//    }
//
//    private void initComponents() {
//        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
//        scrollPane1 = new JScrollPane();
//        table1 = new JTable();
//
//        //======== this ========
//
//        //======== scrollPane1 ========
//        {
//
//            //---- table1 ----
//            table1.setModel(new DefaultTableModel(
//                new Object[][] {
//                    {null, null, null},
//                    {null, null, null},
//                },
//                new String[] {
//                    "\u7f16\u53f7", "\u540d\u79f0", "\u6570\u91cf"
//                }
//            ));
//            scrollPane1.setViewportView(table1);
//        }
//
//        GroupLayout layout = new GroupLayout(this);
//        setLayout(layout);
//        layout.setHorizontalGroup(
//            layout.createParallelGroup()
//                .addGroup(layout.createSequentialGroup()
//                    .addGap(55, 55, 55)
//                    .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
//                    .addContainerGap(68, Short.MAX_VALUE))
//        );
//        layout.setVerticalGroup(
//            layout.createParallelGroup()
//                .addGroup(layout.createSequentialGroup()
//                    .addGap(36, 36, 36)
//                    .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
//                    .addContainerGap(107, Short.MAX_VALUE))
//        );
//        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
//    }
//
//    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
//    private JScrollPane scrollPane1;
//    private JTable table1;
//    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
//}
//

package com.hafu.view;
        import com.hafu.model.KuCun;
        import com.hafu.service.KuCunService;
        import java.awt.*;
        import java.util.ArrayList;
        import java.util.Vector;
        import javax.swing.*;
        import javax.swing.GroupLayout;
        import javax.swing.table.*;
public class KuCunFrm extends JFrame {
    private KuCunService kuCunService= new KuCunService();
    public KuCunFrm() {
        initComponents();
        fillTableData();
    }
    private void fillTableData() {
        DefaultTableModel model = (DefaultTableModel) table1.getModel();
        model.setRowCount(0);
        ArrayList<KuCun> list=kuCunService.getKuCunList();
        for (KuCun kuCun : list) {
            Vector<Object> rowData = new Vector<>();
            rowData.add(kuCun.getId());
            rowData.add(kuCun.getSpname());
            rowData.add(kuCun.getNum());
            model.addRow(rowData);
        }
    }
    private void initComponents() {
        scrollPane1 = new JScrollPane();
        table1 = new JTable();
        setTitle("\u5e93\u5b58\u8be6\u5355");
        Container contentPane = getContentPane();
        {
            table1.setModel(new DefaultTableModel(
                    new Object[][] {
                            {null, null, null},
                            {null, null, null},
                    },
                    new String[] {
                            "\u7f16\u53f7", "\u540d\u79f0", "\u6570\u91cf"
                    }
            ));
            scrollPane1.setViewportView(table1);
        }
        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
                contentPaneLayout.createParallelGroup()
                        .addGroup(contentPaneLayout.createSequentialGroup()
                                .addGap(52, 52, 52)
                                .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 667, GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(119, Short.MAX_VALUE))
        );
        contentPaneLayout.setVerticalGroup(
                contentPaneLayout.createParallelGroup()
                        .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
                                .addContainerGap(33, Short.MAX_VALUE)
                                .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addGap(23, 23, 23))
        );
        pack();
        setLocationRelativeTo(getOwner());
    }
    private JScrollPane scrollPane1;
    private JTable table1;
}

